import imghdr
import os

imgType_list = {'jpg','bmp','png','jpeg'}


target_dir = 'D:\\workspace\\py\\tmp\\unknown'

for item in os.listdir(target_dir):
    file_path = os.path.join(target_dir, item)
    print(file_path)
    # imghdr 可以用来判断文件是否是图片
    what = imghdr.what(file_path)
    if what in imgType_list:
        print(what)